package com.amado.course48Generics;

import java.util.ArrayList;
import java.util.List;

public class Page<T> {
	/**
	 * 一页展示多少条数据
	 */
	private int pageSize = 3;
	/**
	 * 当前页
	 */
	private int currentPage = 1;
	/**
	 * 一共有多少页
	 */
	private int totalPage;
	/**
	 * 总共数据条数
	 */
	private int count;

	/**
	 * 返回的列表数据
	 */
	private List<T> list;
	

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		// 统计有多少页
		totalPage = count / pageSize + (count % pageSize == 0 ? 0 : 1);
		this.count = count;
	}

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	public Page() {

	}

	public Page(int currentPage, int pageSize) {
		super();
		this.currentPage = currentPage;
		this.pageSize = pageSize;
	}
	public static void main(String[] args) {
		List<String> strList = new ArrayList<>();
		List<Integer> intList = new ArrayList<>();
		Page<String> page = new Page<>();
		page.setList(null);
		page.getList();
		//所有类型都可以，相当于object
		Page<?> page2 = new Page();
		page2.getList();
		
		Page<Object> page3 = new Page();
		page3.getList();
		
		Page page4 = new Page();
		page4.getList();
	}

}
